package renta_peliculas;

import javax.swing.table.DefaultTableModel;
import java.sql.*;
import java.util.LinkedList;
import javax.swing.JOptionPane;

public class trabajador extends javax.swing.JFrame {
//declaracion de variables
    DefaultTableModel model;
    Connection miConexion;
    Statement sent;
    enum ModoEdicion {

        INSERTAR, MODIFICAR, LEER
    }
    ModoEdicion ME;
    //FIN declaracion de variables
    public trabajador() {
        initComponents();
        miConexion = conexion.GetConnection();
        ME = ModoEdicion.LEER;
        this.HabilitaControles(false);
        this.Limpiar();
        this.Llenar();
    }
    void HabilitaControles(boolean habilita) {
        this.txt_nombre.setEditable(habilita);
        this.txt_edad.setEnabled(habilita);
        this.txt_domicilio.setEditable(habilita);
        this.txt_correo_electronico.setEditable(habilita);
        this.txt_telefono.setEditable(habilita);
        this.txt_salario.setEnabled(habilita);
        if (habilita == true) {
            this.txt_nombre.requestFocus();
        }
        this.btn_insertar.setEnabled(ME == ModoEdicion.LEER);
        this.btn_modificar.setEnabled(false);
        this.btn_borrar.setEnabled(false);
        this.btn_guardar.setEnabled(ME != ModoEdicion.LEER);
        this.btn_cancelar.setEnabled(ME != ModoEdicion.LEER);
    }
    void Limpiar() {
        this.txt_nombre.setText("");
        this.txt_edad.setValue(1);
        this.txt_domicilio.setText("");
        this.txt_correo_electronico.setText("");
        this.txt_telefono.setText("");
        this.txt_salario.setValue(0);
    }
    void Llenar() {
        try {
            String[] titulos = {"id_trabajador", "nombre", "edad", "domicilio", "correo_electronico", "telefono", "salario"};
            String sql = "select * from trabajador;";
            model = new DefaultTableModel(null, titulos);
            sent = miConexion.createStatement();
            ResultSet rs = sent.executeQuery(sql);
            String[] fila = new String[7];
            while (rs.next()) {
                fila[0] = rs.getString("id_trabajador");
                fila[1] = rs.getString("nombre");
                fila[2] = rs.getString("edad");
                fila[3] = rs.getString("domicilio");
                fila[4] = rs.getString("correo_electronico");
                fila[5] = rs.getString("telefono");
                fila[6] = rs.getString("salario");
                model.addRow(fila);
            }
            this.tbl_trabajador.setModel(model);
            //se oculta la columna id
            this.tbl_trabajador.getColumnModel().getColumn(0).setMaxWidth(0);
            this.tbl_trabajador.getColumnModel().getColumn(0).setMinWidth(0);
            this.tbl_trabajador.getColumnModel().getColumn(0).setPreferredWidth(0);

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Error 1 " + ex.getMessage(), "Error 1 ", JOptionPane.ERROR_MESSAGE);
        }
    }
    private boolean ValidaCampos() {
        boolean result = true;
        String Error = "";
        if (this.txt_nombre.getText().trim().length() == 0) {
            Error = "El campo nombre no debe ir vacio";
            result = false;
        } else if (this.txt_domicilio.getText().trim().length() == 0) {
            Error = "El campo domicilio no debe ir vacio";
            result = false;
        } else if (this.txt_correo_electronico.getText().trim().length() == 0) {
            Error = "El campo E-MAIL no debe ir vacio";
            result = false;
        } else if (this.txt_telefono.getText().trim().length() == 0) {
            Error = "El campo telefono no debe ir vacio";
            result = false;
        }
        if (Error != "") {
            JOptionPane.showMessageDialog(null, Error, "Error", JOptionPane.ERROR_MESSAGE);
        }
        return result;
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        btn_insertar = new javax.swing.JButton();
        btn_modificar = new javax.swing.JButton();
        btn_borrar = new javax.swing.JButton();
        btn_guardar = new javax.swing.JButton();
        btn_cancelar = new javax.swing.JButton();
        btn_refrescar = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbl_trabajador = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txt_nombre = new javax.swing.JTextField();
        txt_edad = new javax.swing.JSpinner();
        jScrollPane2 = new javax.swing.JScrollPane();
        txt_domicilio = new javax.swing.JTextArea();
        txt_correo_electronico = new javax.swing.JTextField();
        txt_telefono = new javax.swing.JTextField();
        txt_salario = new javax.swing.JSpinner();

        btn_insertar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/add.png"))); // NOI18N
        btn_insertar.setToolTipText("Insertar");
        btn_insertar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_insertarActionPerformed(evt);
            }
        });

        btn_modificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/editar.png"))); // NOI18N
        btn_modificar.setToolTipText("Modificar");
        btn_modificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_modificarActionPerformed(evt);
            }
        });

        btn_borrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/borrar.png"))); // NOI18N
        btn_borrar.setToolTipText("Eliminar");
        btn_borrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_borrarActionPerformed(evt);
            }
        });

        btn_guardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/guardar.png"))); // NOI18N
        btn_guardar.setToolTipText("Guardar");
        btn_guardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_guardarActionPerformed(evt);
            }
        });

        btn_cancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/cancel.png"))); // NOI18N
        btn_cancelar.setToolTipText("Cancelar");
        btn_cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_cancelarActionPerformed(evt);
            }
        });

        btn_refrescar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/refresh.png"))); // NOI18N
        btn_refrescar.setToolTipText("Refrescar");
        btn_refrescar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_refrescarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(btn_insertar))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btn_modificar)
                            .addComponent(btn_borrar)
                            .addComponent(btn_refrescar)
                            .addComponent(btn_cancelar)
                            .addComponent(btn_guardar))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btn_insertar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_modificar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_borrar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_refrescar)
                .addGap(50, 50, 50)
                .addComponent(btn_guardar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_cancelar)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        tbl_trabajador.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tbl_trabajador.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbl_trabajadorMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tbl_trabajador);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 472, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );

        jLabel1.setText("Nombre completo:");

        jLabel2.setText("Edad:");

        jLabel3.setText("Domicilio:");

        jLabel4.setText("E-Mail:");

        jLabel5.setText("Teléfono:");

        jLabel6.setText("Salario:");

        txt_edad.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1)));

        txt_domicilio.setColumns(20);
        txt_domicilio.setRows(5);
        jScrollPane2.setViewportView(txt_domicilio);

        txt_salario.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), Float.valueOf(0.0f), null, Float.valueOf(1.0f)));
        txt_salario.setDoubleBuffered(true);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addGap(14, 14, 14)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txt_nombre)
                            .addComponent(jScrollPane2)
                            .addComponent(txt_correo_electronico)
                            .addComponent(txt_telefono)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txt_edad, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txt_salario, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addGap(6, 6, 6)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(105, 105, 105)))
                .addGap(2, 2, 2))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel1))
                    .addComponent(txt_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel2))
                    .addComponent(txt_edad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(4, 4, 4)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jScrollPane2))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel4))
                    .addComponent(txt_correo_electronico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel5))
                    .addComponent(txt_telefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jLabel6))
                    .addComponent(txt_salario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9))
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_insertarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_insertarActionPerformed
        // Se limpian los datos y luego se habilitan para escribir dentro de éste
        ME = ModoEdicion.INSERTAR;
        this.Limpiar();
        this.HabilitaControles(true);
    }//GEN-LAST:event_btn_insertarActionPerformed

    private void btn_modificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_modificarActionPerformed
        // TODO add your handling code here:
        ME = ModoEdicion.MODIFICAR;
        this.HabilitaControles(true);
    }//GEN-LAST:event_btn_modificarActionPerformed

    private void btn_guardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_guardarActionPerformed
        // TODO add your handling code here:
        try {
            String query = "";
            if (this.ValidaCampos() == true) {
                if (ME == ModoEdicion.INSERTAR) {
                    query = "insert into trabajador (nombre, edad, domicilio, "
                            + "correo_electronico, telefono, salario) values (?,?,?,?,?,?)";
                    PreparedStatement ps = miConexion.prepareCall(query);
                    ps.setString(1, this.txt_nombre.getText().toUpperCase().trim());
                    ps.setString(2, this.txt_edad.getValue().toString());
                    ps.setString(3, this.txt_domicilio.getText().toUpperCase().trim());
                    ps.setString(4, this.txt_correo_electronico.getText().trim());
                    ps.setString(5, this.txt_telefono.getText().trim());
                    ps.setString(6, this.txt_salario.getValue().toString());
                    int result = ps.executeUpdate();
                    ME = ModoEdicion.LEER;
                    this.Limpiar();
                    this.Llenar();
                    this.HabilitaControles(false);
                    if (result > 0) {
                        JOptionPane.showMessageDialog(null, "Datos Guardados correctamente");
                    } else {
                        JOptionPane.showMessageDialog(null, "ERROR", "Occurrió un error al guardar la información.", JOptionPane.ERROR_MESSAGE);
                    }

                } else if (ME == ModoEdicion.MODIFICAR) {
                    query = "update trabajador set nombre=?, edad=?, domicilio=?, "
                            + "correo_electronico=?, telefono=?, salario=? where id_trabajador=?";
                    int fila = this.tbl_trabajador.getSelectedRow();
                    String id_trabajador = (String) this.tbl_trabajador.getValueAt(fila, 0);
                    PreparedStatement ps = miConexion.prepareCall(query);
                    ps.setString(1, this.txt_nombre.getText().toUpperCase().trim());
                    ps.setString(2, this.txt_edad.getValue().toString());
                    ps.setString(3, this.txt_domicilio.getText().toUpperCase().trim());
                    ps.setString(4, this.txt_correo_electronico.getText().trim());
                    ps.setString(5, this.txt_telefono.getText().trim());
                    ps.setString(6, this.txt_salario.getValue().toString());
                    ps.setString(7, id_trabajador);
                    int result = ps.executeUpdate();
                    ME = ModoEdicion.LEER;
                    this.Limpiar();
                    this.Llenar();
                    this.HabilitaControles(false);
                    if (result > 0) {
                        JOptionPane.showMessageDialog(null, "Datos Modificados correctamente");
                    } else {
                        JOptionPane.showMessageDialog(null, "ERROR", "Occurrió un error al guardar la información.", JOptionPane.ERROR_MESSAGE);
                    }
                }
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Error 2 " + ex.getMessage(), "Error 2", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_btn_guardarActionPerformed

    private void btn_cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_cancelarActionPerformed
        // TODO add your handling code here:
        ME = ModoEdicion.LEER;
        this.HabilitaControles(false);
    }//GEN-LAST:event_btn_cancelarActionPerformed

    private void btn_refrescarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_refrescarActionPerformed
        // TODO add your handling code here:
        ME = ModoEdicion.LEER;
        this.Llenar();
        this.Limpiar();
        this.HabilitaControles(false);
    }//GEN-LAST:event_btn_refrescarActionPerformed

    private void tbl_trabajadorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbl_trabajadorMouseClicked
        // TODO add your handling code here:
        if (evt.getButton() == 1) {
            int fila = this.tbl_trabajador.getSelectedRow();
            try {
                this.HabilitaControles(false);
                this.btn_modificar.setEnabled(true);
                this.btn_borrar.setEnabled(true);
                String sql = "select * from trabajador where id_trabajador = " + this.tbl_trabajador.getValueAt(fila, 0);
                sent = miConexion.createStatement();
                ResultSet rs = sent.executeQuery(sql);
                rs.next();
                this.txt_nombre.setText(rs.getString("nombre"));
                this.txt_edad.setValue(rs.getInt("edad"));
                this.txt_domicilio.setText(rs.getString("domicilio"));
                this.txt_correo_electronico.setText(rs.getString("correo_electronico"));
                this.txt_telefono.setText(rs.getString("telefono"));
                this.txt_salario.setValue(rs.getDouble("salario"));
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, "Error 3 " + ex.getMessage(), "Error 3 ", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_tbl_trabajadorMouseClicked

    private void btn_borrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_borrarActionPerformed
        // TODO add your handling code here:
        int fila = this.tbl_trabajador.getSelectedRow();
        try {
            String sql = "delete from trabajador where id_trabajador = " + this.tbl_trabajador.getValueAt(fila, 0);
            sent = miConexion.createStatement();
            int rs = sent.executeUpdate(sql);
            if (rs > 0) {
                JOptionPane.showMessageDialog(null, "Datos Eliminados correctamente");
            } else {
                JOptionPane.showMessageDialog(null, "Occurrió un error al eliminar la información.", "ERROR", JOptionPane.ERROR_MESSAGE);
            }
            ME = ModoEdicion.LEER;
            this.Limpiar();
            this.Llenar();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Error 4 " + ex.getMessage(), "Error 4 ", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_btn_borrarActionPerformed

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(trabajador.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(trabajador.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(trabajador.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(trabajador.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new trabajador().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_borrar;
    private javax.swing.JButton btn_cancelar;
    private javax.swing.JButton btn_guardar;
    private javax.swing.JButton btn_insertar;
    private javax.swing.JButton btn_modificar;
    private javax.swing.JButton btn_refrescar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable tbl_trabajador;
    private javax.swing.JTextField txt_correo_electronico;
    private javax.swing.JTextArea txt_domicilio;
    private javax.swing.JSpinner txt_edad;
    private javax.swing.JTextField txt_nombre;
    private javax.swing.JSpinner txt_salario;
    private javax.swing.JTextField txt_telefono;
    // End of variables declaration//GEN-END:variables
}
